package org.jeecg.modules.apiacl.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.apiacl.entity.TaxApiaclAuthorize;
import org.jeecg.modules.apiacl.service.ITaxApiaclAuthorizeService;
import org.jeecg.modules.innerApi.zhiYunSdApi.enums.SdApiEnum;
import org.jeecg.modules.innerApi.zhiYunSdApi.requestVo.SdCxhzxxbrc112Param;
import org.jeecg.modules.innerApi.zhiYunSdApi.requestVo.SdHqbswjrc15Param;
import org.jeecg.modules.innerApi.zhiYunSdApi.requestVo.SdHqxfnsrxxrc18Param;
import org.jeecg.modules.innerApi.zhiYunSdApi.responseVo.SdCxhzxxbcc112Rtn;
import org.jeecg.modules.innerApi.zhiYunSdApi.responseVo.SdHqbswjcc15Rtn;
import org.jeecg.modules.innerApi.zhiYunSdApi.responseVo.SdHqxfnsrxxcc18Rtn;
import org.jeecg.modules.innerApi.zhiYunSdApi.util.ShudianResponse;
import org.jeecg.modules.innerApi.zhiYunSdApi.util.ZhiyunSdApiCallUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description:
 * @author: niugeng
 * @create: 2023-08-30 14:50
 **/
@Api(tags = "数电接口测试")
@RestController
@RequestMapping("/test")
@Slf4j
public class TestSdController extends JeecgController<TaxApiaclAuthorize, ITaxApiaclAuthorizeService> {

    @Autowired
    private ZhiyunSdApiCallUtil shudianApiCallUtil;

    @GetMapping("/t1")
    @ApiOperation(value = "获取版式文件", notes = "获取版式文件")
    private String test() {

        final ShudianResponse request = shudianApiCallUtil.request(SdApiEnum.HQBSWJCC.getValue()
                , SdHqbswjrc15Param.builder()
                        .downflag("1")
                        .addSeal("1")
                        .fphm("22512000000000007325")
                        .nsrsbh("915101820724315989")
                        .kprq("20230201120326")
                        .build(), new TypeReference<ShudianResponse<SdHqbswjcc15Rtn>>() {
                });

        return JSON.toJSONString(request);
    }

    @GetMapping("/t2")
    @ApiOperation(value = "获取销方纳税人信息", notes = "获取销方纳税人信息")
    private String test2() {

        final SdHqxfnsrxxcc18Rtn request = shudianApiCallUtil.request(SdApiEnum.HQXFNSRXXCC.getValue()
                , SdHqxfnsrxxrc18Param.builder()
                        .nsrsbh("915101820724315989")
                        .build(), SdHqxfnsrxxcc18Rtn.class);


        return JSON.toJSONString(request);
    }


    @GetMapping("/t3")
    @ApiOperation(value = "查询红字信息表", notes = "查询红字信息表")
    private String test4() {


        TypeReference<ShudianResponse<List<SdCxhzxxbcc112Rtn>>> typeReference = new TypeReference<ShudianResponse<List<SdCxhzxxbcc112Rtn>>>() {};

        final SdCxhzxxbrc112Param build = SdCxhzxxbrc112Param.builder()
                .nsrsbh("915101820724315989")
                .kprqq("20210101")
                .kprqz("20230831")
                .page("1")
                .size("10")
                .build();

        final ShudianResponse<List<SdCxhzxxbcc112Rtn>> request = shudianApiCallUtil.request(SdApiEnum.CXHZXXBCC.getValue(), build, typeReference);

        return JSON.toJSONString(request);
    }


}
